package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.constant.ShoppingRetCode;
import com.cskaoyan.shopping.dal.entitys.PanelContentItem;
import com.cskaoyan.shopping.dto.HomePageResponse;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.service.IHomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cskaoyan.mall.commons.result.ResponseUtil;

import java.util.List;

/**
 * @Author Ajun de BBC
 * @Date 2022/8/1 9:27
 * @Version 1.5
 */

@Slf4j
@RestController
@RequestMapping("shopping")
public class HomeController {


    @Autowired
    IHomeService iHomeService;

    @RequestMapping("homepage")
    public ResponseData getAllHomepage(){
       HomePageResponse response = iHomeService.homepage();

        if(ShoppingRetCode.SUCCESS.getCode().equals(response.getCode())){
            return new ResponseUtil().setData(response.getPanelContentItemDtos(),response.getMsg());
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
